.TH FIR 1 "25 February 2006" "WFDB 10.4.0" "WFDB Applications Guide"
.SH NAME
fir \- general-purpose FIR filter for WFDB records
.SH SYNOPSIS
\fBfir\fR [ \fIoptions\fR ... ] \fB-c\fR [ \fIcoefficients\fR ... ]
.SH DESCRIPTION
\fIfir\fR can be used to apply any desired finite impulse response filter
to any desired section of a waveform database record.
\fIOptions\fR are:
.TP
\fB-c\fR \fIcoefficient\fR [ \fIcoefficient\fR ... ]
Filter using the specified \fIcoefficients\fR (must be the last option;
\fB-c\fR marks the beginning of the coefficient list).
.TP
\fB-C\fR \fIfile\fR
Read the filter coefficients from the specified file rather than from the
argument list.
.TP
\fB-f\fR \fItime\fR
Filter from the specified \fItime\fR on the input record (default: start at the
beginning of the record).
.TP
\fB-h\fR
Print a usage summary.
.TP
\fB-H\fR
Read the signal files in high-resolution mode (default: standard mode).
These modes are identical for ordinary records.  For multifrequency records,
the standard decimation of oversampled signals to the frame rate is suppressed
in high-resolution mode (rather, all other signals are resampled at the highest
sampling frequency).
.TP
\fB-i\fR \fIrecord\fR
Use the specified \fIrecord\fR for input (default: record 16).
.TP
\fB-n\fR \fIrecord\fR
Create a header file for the output signals, with the specified \fIrecord\fR
name.  The signal descriptions are copied from those of the input signals.
.TP
\fB-o\fR \fIrecord\fR
Use the specified \fIrecord\fR for output (default: record 16).
.TP
\fB-ri\fR
Rectify the input (i.e., take its absolute value) before filtering.
.TP
\fB-ro\fR
Rectify the filtered output.
.TP
\fB-s\fR \fIshift\fR
To compensate for phase shift, read ahead on the input record by the specified
interval before starting the filter.  \fIShift\fR is specified in standard
time format (use \fBs\fR\fInn\fR to compensate for a phase shift of \fInn\fR
samples).
.TP
\fB-t\fR \fItime\fR
Filter until the specified \fItime\fR on the input record (default: go to the
end of the record).
.PP
Unless the \fB-C\fR option is used, the \fB-c\fR argument should appear at the
end of the option list.  Filter coefficients are real numbers separated by
spaces;  the last coefficient is applied to the most recent input sample.
.PP
In the present implementation, the same filter is applied to each input signal.
If the output record header file specifies fewer signals than are present in
the input, any extra input signals are discarded.
.SH ENVIRONMENT
.PP
It may be necessary to set and export the shell variable \fBWFDB\fR (see
\fBsetwfdb\fR(1)).
.SS Examples
.PP
A low-pass "boxcar" filter:
.br
	\fBfir -c .2 .2 .2 .2 .2\fR
.PP
The complementary high-pass filter:
.br
	\fBfir -c -.2 -.2 .8 -.2 -.2\fR
.PP
An attenuator:
.br
	\fBfir -c .4\fR
.PP
A differentiator:
.br
	\fBfir -c -1 1\fR
.PP
A 60-Hz notch filter, with partial correction for phase shift,
for the MIT\-BIH database (360 samples/second):
.br
	\fBfir -s s2 -c .5 0 0 .5\fR
.PP
A "triangle" filter for QRS detection (at 128 samples/second):
.br
	\fBfir -s s8 -c -1 -2 -3 -4 -1 2 5 8 5 2 -1 -4 -3 -2 -1\fR
.SH SEE ALSO
.PP
\fBmfilt\fR(1)
.SH AUTHOR
George B. Moody (george@mit.edu)
.SH SOURCE
http://www.physionet.org/physiotools/wfdb/app/fir.c
